<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增批量入库')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-rukuTest-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">购货日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="chukuDate" class="form-control" placeholder="yyyy-MM-dd" type="text"
                               th:value="${#dates.format(#calendars.createNow(), 'yyyy-MM-dd')}" >
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">入库操作人：</label>
                <div class="col-sm-8">
                    <input name="rukuMen" class="form-control" type="text"
                           th:value="${session.name4user}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品类别：</label>
                <div class="col-sm-8">
                    <select name="shangpinLeibie" class="form-control">
                        <option onclick="change2down4select(1)" value="整套门">整套门</option>
                        <option onclick="change2down4select(7)" value="双开门左扇">双开门左扇</option>
                        <option onclick="change2down4select(8)" value="双开门右扇">双开门右扇</option>
                        <option onclick="change2down4select(2)" value="门扇">门扇</option>
                        <option onclick="change2down4select(3)" value="门框">门框</option>
                        <option onclick="change2down4select(4)" value="五金（防火锁）">五金（防火锁）</option>
                        <option onclick="change2down4select(5)" value="五金（闭门器）">五金（闭门器）</option>
                        <option onclick="change2down4select(6)" value="五金（拉爆盖）">五金（拉爆盖）</option>
                    </select>
                    <script type="text/javascript">
                        function change2down4select(value) {
                            switch (value) {
                                case 1:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist1")
                                    break
                                case 2:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist2")
                                    break
                                case 3:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist3")
                                    break
                                case 4:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist4")
                                    break
                                case 5:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist5")
                                    break
                                case 6:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist6")
                                    break
                                case 7:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist7")
                                    break
                                case 8:
                                    document.querySelector('input[id="input4name"]').setAttribute("list","namelist8")
                                    break
                                default:
                                    break
                            }
                        }
                    </script>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品名称：</label>
                <div class="col-sm-8">
                    <input  onchange="changeValue(this.value)" id="input4name" name="shangpinName" class="form-control" type="text" list="namelist1">
                    <datalist id="namelist1" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%整套门%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist2"  th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%门扇%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist3" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%门框%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist4" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%防火锁%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist5" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%闭门器%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist6" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%拉爆盖%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist7" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%左扇%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <datalist id="namelist8" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxi2LeiBie4Name('%右扇%')}">
                        <option  th:each="lists : ${type}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+' | '+lists.getKaiXiang()+'@'+lists.getShangpinShoujia()}"
                                 th:text="${lists.getShangpinName()}">
                        </option>
                    </datalist>
                    <script type="text/javascript">
                        function changeValue(value) {
                            var str = value.split(" | ")[1]
                            var kaixiang = value.split(" | ")[2].split("@")[0]
                            var kuan = str.split("*")[0]
                            var gao = str.split("*")[1]
                            var shoujia = value.split("@")[1]
                            document.getElementById("guiGeKuan").value = kuan
                            document.getElementById("guiGeGao").value = gao
                            document.getElementById("kaiXiang").value = kaixiang
                            document.getElementById("input4name").value = value.split(" | ")[0]
                            document.getElementById("shoujia").value = shoujia
                        }
                    </script>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">规格宽：</label>
                <div class="col-sm-8">
                    <input id="guiGeKuan" name="guiGeKuan" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">规格高：</label>
                <div class="col-sm-8">
                    <input id="guiGeGao" name="guiGeGao" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开向：</label>
                <div class="col-sm-8">
                    <input name="kaiXiang"  class="form-control" id="kaiXiang">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品数量：</label>
                <div class="col-sm-8">
                    <input name="shuLiang" class="form-control" type="text" value="1">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品单价：</label>
                <div class="col-sm-8">
                    <input id="shoujia" name="danJia" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="beizhu" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "piliangruku/rukuTest"
        $("#form-rukuTest-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-rukuTest-add').serialize());
            }
        }

        $("input[name='gouhuoDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>